<!DOCTYPE html>
<html  lang="en" xmlns:th="http://www.thymeleaf.org">
    <head>
        <meta charset="utf-8">
        <title>
          用户信息管理
        </title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" th:href="@{/css/x-admin.css}" media="all">
    </head>
    <body>
        <div class="x-nav">
            <span class="layui-breadcrumb">
              <a><cite>用户列表</cite></a>
            </span>
            <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"  href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon" style="line-height:30px">ဂ</i></a>
        </div>
        <div class="x-body">
        
        
        <xblock><button class="layui-btn" onclick="member_add('添加用户','/touser/adduser','550','400')"><i class="layui-icon">&#xe608;</i>添加</button><span class="x-right" style="line-height:40px">总 [[${pageInfo.total } ]]条记录</span></xblock>
            <table class="layui-table">
                <thead>
                    <tr>
                     	  <th>用户ID</th>
                          <th>用户名</th>
						  <th>注册日期</th>
						  <th>邮箱</th>
						  <th>状态</th>
						  <th>操作</th>
                    </tr>
                </thead>
                <tbody id="x-link">
                    <tr  th:each="user:${pageInfo.list}">
                     	<td class="center" th:text="${user.id}" ></td>
						<td class="center" th:text="${user.username}"></td>
						<td class="center">[[${#dates.format(user.createdate, 'dd/MMM/yyyy HH:mm')}]]</td>
						 <td class="center">
							<span class="center">[[${user.email}]]</span>
						</td>
						
						<td class="center">
							<span class="layui-btn layui-btn-normal">[[${user.Active}]]</span>
						</td>
						<td class="center">
							<a class="layui-btn layui-btn-warm" href="">
								 <i class="layui-icon">&#xe642;</i>  
								Edit                                            
							</a>
							<a class="layui-btn layui-btn-danger" href="javascript:;" onclick="commemt_del(this,$(this).parents('tr').find('td')[0].innerHTML)" >
								 <i class="layui-icon">&#xe640;</i> 
								Delete
							</a>
						</td>
				  </tr>
                </tbody>
            </table>

            <div id="page"></div>
            
        
            
            
            
            
        </div>
        
   <!--=====================================javascript================================= -->     
       	<script th:src="@{/lib/layui/layui.js}" charset="utf-8"></script>
        <script th:src="@{/js/x-layui.js}" charset="utf-8"></script>
        
        
        
        <script   type="text/javascript" th:inline="javascript" >
        console.log([[${pageInfo}]]);
       
            layui.use(['element','laypage','layer','form'], function(){
              $ = layui.jquery;//jquery
              lement = layui.element();//面包导航
              laydate = layui.laydate;//日期插件
              laypage = layui.laypage;//分页
              layer = layui.layer;//弹出层
              form = layui.form();//弹出层
          
              
              
              
               //  1)分页插件
	                //以上模块根据需要引入
		              laypage({
		                cont: 'page'
		                ,pages: [[${pageInfo.pages }]]
		                ,curr: [[${pageInfo.pageNum }]]
		              	,first: '首页'
		            	,last: '尾页'
		                ,prev: '<em><</em>'
		                ,next: '<em>></em>'
		                ,jump : function(obj, first){
		                	if (!first) {
		                	     var pn=obj.curr;
		                	    window.location.href="/touser/alluser_admin?pn="+pn;//跳转链接
		                	    }
		                }	
		                
		                
		              }); 
                 
		              
              
          })

          
           
              
              
              
              
              
//==================================================================================//
	/* 添加新用户（初始添加不带任何权限） */
            function member_add(title,url,w,h){
                x_admin_show(title,url,w,h);
            }



	/* 用户添加完成后，通过update更新具体权限 */


            //批量删除提交
	        function delAll () {
	           layer.confirm('确认要删除吗？',function(index){
	           	
	               //捉到所有被选中的，发异步进行删除
	               layer.msg('删除成功', {icon: 1});
	           });
	        }
            
            var basePath = [[${#httpServletRequest.getScheme() + "://" + #httpServletRequest.getServerName() + ":" + #httpServletRequest.getServerPort() + #httpServletRequest.getContextPath()}]];
               
            /* 单用户删除模块  */
            function commemt_del(obj,id){
            	//alert(id+basePath);
             	 layer.confirm('确认要删除吗？',function(index){
                    //发异步删除数据
                    $.ajax({
                    	url: basePath+'/touser/user?id=' +id,
                    	type: 'DELETE',
                    	dataType: 'json',
                    	async: false,
                    	success:function(result){
                    		console.log(result);
                    		if(result.content=="success"){
		                    $(obj).parents("tr").remove();
		                    location.reload();
		                    layer.msg('已删除!',{icon:1,time:1000});
		                    
                    		}else{
                    		layer.msg('删除失败!',{icon:2,time:1000});
                    		}
                    		
                    	}
                    });
                    
                }); 
            }
            
            
         
         
            
            
            </script>
            
    </body>
</html>